home *** CD-ROM | disk | FTP | other *** search
/ Tech Arsenal 1 / Tech Arsenal (Arsenal Computer).ISO / tek-01 / strlib.zip / STRNMOV.C < prev    next >
Text File  |  1993-01-04  |  896b  |  31 lines

  1.  
  2. /*  File   : strnmov.c
  3.     Author : Richard A. O'Keefe.
  4.     Updated: 20 April 1984
  5.     Defines: strnmov()
  6.  
  7.     strnmov(dst, src, n) moves up to n characters of  src  to  dst.   It
  8.     always  moves  exactly n characters to dst; if src is shorter than n
  9.     characters dst will be extended on the right with NULs, while if src
  10.     is longer than n characters dst will be a truncated version  of  src
  11.     and  will  not  have  a closing NUL.  The result is a pointer to the
  12.     first NUL in dst, or is dst+n if dst was truncated.
  13. */
  14.  
  15. #include "strings.h"
  16.  
  17. char *strnmov(dst, src, n)
  18.     register char *dst, *src;
  19.     register int n;
  20.     {
  21.         while (--n >= 0) {
  22.             if (!(*dst++ = *src++)) {
  23.                 src = dst-1;
  24.                 while (--n >= 0) *dst++ = NUL;
  25.                 return src;
  26.             }
  27.         }
  28.         return dst;
  29.     }
  30.  
  31.